<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <script src="./js/jquery.min.js"></script>
    <script src="./js/axios.min.js"></script>
    <link rel="stylesheet" href="./layui/css/layui.css">
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>添加用户</legend>
</fieldset>

<form id="myForm" action="${pageContext.request.contextPath}/role?type=addParent" method="post" class="layui-form">

    <div class="layui-form-item">
        <label class="layui-form-label" for="menuName">菜单名</label>
        <div class="layui-input-block">
            <input type="text" name="menuName" id="menuName" placeholder="请输入"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">分配角色</label>
        <div class="layui-input-block">
            <c:forEach items="${requestScope.roleList}" var="roleInfo">
                <input type="checkbox" name="roleId" value="${roleInfo.roleId}" title="${roleInfo.roleName}">
            </c:forEach>
        </div>
    </div>
    <hr>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button id="btn" type="button" class="layui-btn">添加</button>
        </div>
    </div>
</form>

<script src="./layui/layui.js"></script>
<script>
    layui.use('form', function () {
        var form = layui.form;

        //各种基于事件的操作，下面会有进一步介绍
    });
</script>

<script>
    let myForm = $("#myForm");
    let btn = $("#btn");
    let menuName = $("#menuName");
    btn.on("click", function () {
        if (menuName === "") {
            alert("菜单名不可为空！");
            return;
        }
        axios.get("${pageContext.request.contextPath}/")
    });

</script>

</body>
</html>
